<?php
function genericEmailFormat($name, $number, $email, $inq, $siteName)
{
	$datevars = getdate();
	$dateToday=$datevars['year'].'-'.$datevars['mon'].'-'.$datevars['mday'];
	$now = dateParser(explode("-", $dateToday));
	$display = '
<html>
<head>
	<title>Site Inquiry: '.$now.'</title>
	<link href="http://www.clickmediaph.com/commons/reset.css" media="screen" type="text/css" rel="stylesheet" />
	<link href="http://www.clickmediaph.com/commons/960.css" media="screen" type="text/css" rel="stylesheet" />
	<link href="http://www.clickmediaph.com/commons/text.css" media="screen" type="text/css" rel="stylesheet" />
<style type="text/css">
body{
	color: #555;
	font: 10pt/1.2 Arial;
}
#headContent{
	padding-top: 20px;
}
.headText{
	font-size: 16pt;
	text-transform: uppercase;
	font-weight: bold;
	padding-top: 50px;
}
.labels{
	font-weight: bold;
	text-transform: uppercase;
}
#inquiryTitle{
	font-weight: bold;
	text-transform: uppercase;
}
.clear{
clear: both;
}
</style>
</head>
<body>
	<div id="content">
		<div class="container_12">
			<div class="grid_3 alpha">
				<div id="headContent">
					<img src="http://www.clickmediaph.com/commons/cmLogo200.png" />
				</div>				
			</div>
			<div class="grid_9 omega">
				<div class="headText">Site Inquiry: '.$now.'</div>
				<div class="headCont">Acquired through: '.$siteName.'</div>
			</div>
		</div>
		<div class="clear">
		<!--spanner-->
		</div>
		<div class="container_12">
			<div class="grid_12 alpha">
				<div style="border-bottom: 1px dashed #333; margin-top: 5px; margin-bottom:5px;">
				</div>
			</div>
		</div>
		
		<div class="container_12">
			<div class="grid_6 alpha">
				<div class="labels">From:</div>
			</div>
			<div class="grid_6 omega">
				'.$name.'
			</div>
		</div>
		<div class="container_12">
			<div class="grid_6 alpha">
				<div class="labels">Contact Number:</div>
			</div>
			<div class="grid_6 omega">
				'.$number.'
			</div>
		</div>
		<div class="container_12">
			<div class="grid_6 alpha">
				<div class="labels">Email:</div>
			</div>
			<div class="grid_6 omega">
				'.$email.'
			</div>
		</div>
		
		<div class="container_12">
			<div class="grid_12 alpha">
				<div style="border-bottom: 1px dashed #333; margin-top: 5px; margin-bottom:5px;">
				</div>
			</div>
		</div>
		
		<div class="container_12">
			<div class="grid_12 alpha">
				<div id="inquiryTitle">Inquiry:</div>
				<div id="inquiryText">
				'.$inq.'
				</div>
			</div>
		</div>
		
		<div class="container_12">
			<div class="grid_12 alpha">
				<div style="border-bottom: 1px dashed #333; margin-top: 5px; margin-bottom:5px;">
				</div>
			</div>
		</div>
		
		<div class="container_12">
			<div class="grid_12 alpha">
				<div style="text-align: center;">
					This email is generated through automation. Please do not reply to this email.
				</div>
			</div>
		</div>
	</div>
	
	
</body>
</html>
	';

return $display;
}


function verifyEmail($email)
{	
	$domain = strstr($email, '@');
	if ($domain == '' || $domain == '@')
	{
		return false;
	}
	else
	{
		$ext = strstr($domain, '.');
		if ($ext == '.' || $ext == '')
		{
			return false;
		}
		else
		{
			$reverse = strrev($email);
			$checker = strstr($reverse, '@');
			if ($checker == '' || $checker == '@')
			{
				return false;
			}
			else
			{
				return true;
			}
		}
	}
}

function sendThisEmail($content, $title, $success, $fail, $sendTo, $fromEmail, $verifyEmail)
{
	$datevars = getdate();
	$dateToday=$datevars['year'].'-'.$datevars['mon'].'-'.$datevars['mday'];
	$getDateNow = dateParser(explode("-", $dateToday));
	
	if ($sendTo == 'default')
	{
		$toSend = 'orders@soleservice.com.ph';
	}
	else
	{
		$toSend = $sendTo;
	}
	
	// multiple recipients
	$to  = $toSend;
/*
	$to  = 'Richard Ong <richard.ong@clickmediaph.com>';
*/
	// subject
	$subject = $title.' Dated: '.$getDateNow;
		
	// message
	$message = $content;
	
	// To send HTML mail, the Content-type header must be set
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	
	if ($fromEmail == 'default')
	{
		$fromEmail = 'Click Media Automated Email Service<site@clickmediaph.com>';
	}
	
	// Additional headers
	$headers .= 'From: '.$fromEmail."\r\n";
	$headers .= 'Cc: ' . "\r\n";
	$headers .= 'Bcc: ' . "\r\n";
	
	// Mail it
	if ($verifyEmail)
	{
/* 		mail($to, $subject, $message, $headers); */
		return $success;
	}
	else
	{
		return $fail;
	}
}

?>